package com.ruoyi.system.service.impl;

import com.ruoyi.system.domain.TourSight;
import com.ruoyi.system.mapper.TourSightMapper;
import com.ruoyi.system.service.ITourSightService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class TourSightService implements ITourSightService {

    @Autowired
    private TourSightMapper TourSightMapper;

    @Override
    public List<TourSight> selectSightList(int cityId) {
        return TourSightMapper.selectSightListByCity(cityId);
    }

    @Override
    public List<TourSight> selectSightList() {
        return TourSightMapper.selectSightList();
    }
    @Override
    public int addSight(TourSight tourSight) {
        try {
            TourSightMapper.addSight(tourSight);
            return tourSight.getId();
        }catch (Exception e){
            e.printStackTrace();
            return 0;
        }
    }
    @Override
    public String updateSight(TourSight TourSight) {
        try {
            TourSightMapper.updateSight(TourSight);
            return "修改成功！";
        }catch (Exception e){
            e.printStackTrace();
            return "修改失败";
        }
    }

    @Override
    public String deleteSight(Integer id) {
        try {
            TourSightMapper.deleteSight(id);
            return "删除成功！";
        }catch (Exception e){
            e.printStackTrace();
            return "删除失败";
        }
    }
}
